package com.chenfubing.ps;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chenfubing.ps.entity.Access;
import com.chenfubing.ps.entity.Car;
import com.chenfubing.ps.entity.Community;
import com.chenfubing.ps.entity.pojo.CountPojo;
import com.chenfubing.ps.entity.pojo.WeekPojo;
import com.chenfubing.ps.mapper.AccessMapper;
import com.chenfubing.ps.mapper.CarMapper;
import com.chenfubing.ps.service.IAccessService;
import com.chenfubing.ps.service.ICommunityService;
import com.chenfubing.ps.service.IndexService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Random;

@SpringBootTest
@RunWith(SpringJUnit4ClassRunner.class)
public class test {

    @Resource
    private IAccessService iAccessService;

    @Resource
    private IndexService indexService;

    @Resource
    private ICommunityService iCommunityService;

    @Resource
    private AccessMapper accessMapper;

    @Resource
    private CarMapper carMapper;


    @Test
    public void test01()
    {
        Page<Access> accessPage = iAccessService.getAccessPage(1, 10);
        accessPage.getRecords().forEach(System.out::println);
    }

    @Test
    public void test02()
    {
        CountPojo countPojo = indexService.getCountPojo();
        System.out.println(countPojo);
    }

    @Test
    public void test03()
    {
        WeekPojo weekPojo = indexService.getWeekPojo();
        System.out.println(weekPojo);
    }

    @Test
    public void test04()
    {
        iCommunityService.addCommunity(new Community().setCommunityName("智慧小区").setCommunitySpaceNumber(400).setCommunityChergesId(2));
    }

    @Test
    public void test05(){
        accessMapper.getExportPojo().forEach(System.out::println);
    }

    @Test
    public void test06()
    {
//
        List<Access> list = iAccessService.list();
        for (Access access : list)
        {
            LocalDateTime dateTime = LocalDateTime.now().minusDays(new Random().nextInt(8));
            access.setCreateTime(dateTime);
                access.setWay(new Random().nextInt(2));
                iAccessService.updateById(access);

        }
    }

    @Test
    public void test ()
    {
        int j = 0;
        while ( j < 10)
        {
            int i = new Random().nextInt(2);
            System.out.println(i);
            j++;
        }
    }
}
